<h2><%=h @project.name %></h2>
<ul class="white">
  <%=h @project.public ? 'Public Project' : 'Private Project' %>
  <li>Due Date: <%= showtime(@project.due_by) %></li>
</ul>
<% if logged_in? and @project.users.include?(current_user) -%>
  <p class="white">
    <% unless current_user.is_owner?(@project) %>
      <%= link_to "Leave Project", project_membership_path(@project.id,@membership.id), :method => :delete, :confirm => "Leave this project?" %>
    <% else %>
      <%= link_to "Delete Project", project_path(@project), :method => :delete, :confirm => "Delete this project? This cannot be undone!" %>
    <% end %>
  </p>
  <h3>Your Assignments</h3>
  <ul class="white">
    <% current_user.assignments.select{|assignment| assignment.task.project == @project}.each do |assignment| %>
      <li>
        <%= link_to "#{assignment.name}", project_task_assignment_path(@project,assignment.task,assignment) %> (Due <%= showtime(assignment.due_by) %>)
      </li>
    <% end -%>
  </ul>
  <h3>Current Members</h3>
  <ul class="white">
    <% @project.memberships.each do |member| -%>
      <li>
        <%= member.user.name %>
        <% if member.is_owner? %>
          (Admin)
        <% elsif member.is_pending? %>
          (Pending)
        <% elsif member.is_request? %>
          (Requested)
        <% end %>
      </li>
    <% end -%>
  </ul>
  <% if logged_in? and current_user.is_owner?(@project) %><p class="white"><%= link_to "Invite Members", new_project_membership_path(@project) %> | <%= link_to "Manage Members", project_memberships_path(@project) %></p><% end %>
  <h3>Gantt Chart</h3>
  <ul class="white">
    <li>
      <%= link_to "#{@project.name} Gantt Chart", gantt_project_path(@project) %>
    </li>
  </ul>
  <h3>Project Discussion</h3>
  <ul class="white">
    <% @project.discussions.each do |discussion| %>
      <li>
        <%= link_to "#{discussion.title}", project_discussion_path(@project,discussion) %>
      </li>
    <% end -%>
      <li>&nbsp;</li>
      <li>
        <strong><%= link_to "Create a Discussion", new_project_discussion_path(@project) %></strong>
      </li>
  </ul>
<% elsif logged_in? -%>
  <p class="white"><%= link_to "Join Project", project_memberships_path(@project), :method => :post %></p>
<% end -%>
